from PyQt5.QtWidgets import QApplication, QMainWindow,QPushButton
from PyQt5.QtCore import QTimer, QDateTime
import sys

from ui.Ui_timer import Ui_ClockWindow
class ClockWindow(QMainWindow):

    def __init__(self):
        super().__init__()
        self.ui = Ui_ClockWindow()
        self.ui.setupUi(self)
        self.pTimer=QTimer()
        self.pTimer.setInterval(1000)  # 设置定时器间隔为1秒
        self.pTimer.timeout.connect(self.update_time)
        self.pTimer.start(1000)

    def update_time(self):
        date_time = QDateTime.currentDateTime()
        self.ui.yearmounth.display(date_time.toString("yyyy-MM-dd "))
        self.ui.time.display(date_time.toString("hh:mm:ss"))

    def init_ui(self):
        pass

if __name__ == '__main__':
    app = QApplication(sys.argv)

    w=ClockWindow()
    w.show()
    sys.exit(app.exec_())
